﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace AddFileHeaders
{
    internal partial class CurrentFilters : UserControl
    {

        public event EventHandler DeleteFilter;

        private List<Filter> filters = null;
        public List<Filter> Filters
        {
            get { return this.filters; }
        }

        public CurrentFilters()
        {

            InitializeComponent();

            this.filters = new List<Filter>();

        }

        public void AddFilter(Filter filter)
        {
            this.filters.Add(filter);
            SingleFilter sfilter = new SingleFilter();
            sfilter.SetFilter(filter);
            sfilter.FilterDeleted += new EventHandler(sfilter_FilterDeleted);
            this.panel.Controls.Add(sfilter);
        }

        private void sfilter_FilterDeleted(object sender, EventArgs e)
        {
            this.RemoveFilter(sender as SingleFilter);
            if (this.DeleteFilter != null) { this.DeleteFilter(sender, e); }
        }

        public void RemoveFilter(SingleFilter sfilter)
        {
            this.panel.Controls.Remove(sfilter);
            this.filters.Remove(sfilter.CurrentFilter);
        }

    }
}
